precision mediump float;

uniform vec3 uLightPosition;
uniform sampler2D uTextureUnit;

varying vec3 vPosition;
varying vec4 vColor;
varying vec3 vNormal;
varying vec2 vTexture;

   void main(){
      float distance=length(uLightPosition-vPosition);
      vec3 lightVector=normalize(uLightPosition-vPosition);
      float diffuse=max(dot(vNormal,lightVector),0.1);
      diffuse=diffuse * (1.0 / (1.0+(0.25*distance*distance)));
      diffuse=diffuse+0.7;//decrease attenuation

      //combined texture with color
      gl_FragColor=vColor*diffuse*texture2D(uTextureUnit,vTexture);//color diffuse light and texture
   }